<html>
<head>
  <title>hi-earth-kml</title>
  <script src="http://www.google.com/jsapi?key=ABQIAAAAWUVF8N8Huu25Pq8GRpK1xxS9oab4P-4fbJ9HAy_bhqOuOmU8HRQL4H-zL-5iLOjiC7rj7HtFQrAIQw"> </script>
  <script type="text/javascript">
    var ge;
    google.load("earth", "1");

    function init() {
      google.earth.createInstance('map3d', initCB, failureCB);
    }

    function initCB(instance) {
      ge = instance;
      ge.getWindow().setVisibility(true);
      var href = "http://gpx-proto.googlecode.com/svn/trunk/js/hi.kml";
      //alert(href);
      google.earth.fetchKml(ge, href, finishFetchKml);
    }

    function finishFetchKml(kmlObject) {
      // check if the KML was fetched properly
      if (kmlObject) {
        // add the fetched KML to Earth
        ge.getFeatures().appendChild(kmlObject);
        if (kmlObject.getAbstractView() !== null) {
          ge.getView().setAbstractView(kmlObject.getAbstractView());
        }
      } else {
        // wrap alerts in API callbacks and event handlers
        // in a setTimeout to prevent deadlock in some browsers
        setTimeout(function() {
          alert('Bad or null KML.');
        }, 0);
      }
    }

    function failureCB(errorCode) {
      alert(errorCode);
    }

    google.setOnLoadCallback(init);
  </script>
</head>
<body>
  <div id="map3d" style="height: 400px; width: 600px;"></div>
</body>
</html>
